using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WallLoop : MonoBehaviour
{
    GameObject mainCam;
    float wall_height = 7;
    float total_height;
    int wallNums = 3;

    private void Start()
    {
        mainCam = GameObject.FindGameObjectWithTag("MainCamera");
        total_height = wall_height * wallNums;
    }

    private void Update()
    {
        Vector3 floor_pos = transform.position;
        if(mainCam.transform.position.y > transform.position.y + total_height / 2)
        {
            floor_pos.y += total_height;
            transform.position = floor_pos;
        }
        else if (mainCam.transform.position.y < transform.position.y - total_height / 2)
        {
            floor_pos.y -= total_height;
            transform.position = floor_pos;
        }
    }
}
